app.controller("baseController",function ($scope) {
    $scope.selectedIds = []; //存放所勾选的ID
    $scope.updateSelection = function($event,id){
        if ($event.target.checked){
            $scope.selectedIds.push(id);//把选中的ID装进数组
        }else{
            var idIndex = $scope.selectedIds.indexOf(id);//得到id的下标
            $scope.selectedIds.splice(idIndex,1);//第一个参数是从几开始，第二个参数是删除几个
        }
    }

    $scope.reloadList = function(){
        $scope.search($scope.pageModel.currentPage,$scope.pageModel.itemsPerPage);
    }
    $scope.pageModel = {
        currentPage: 1,
        totalItems: 50,
        itemsPerPage: 10,
        perPageOptions: [5, 10, 15, 40, 50],
        onChange: function(){
            $scope.reloadList();
        }
    }
    $scope.jsonToStr =function (str,keyName) {
        var attrArray = JSON.parse(str);
        var resultStr = "";
        for (var i=0 ; i<attrArray.length;i++){
            if (i==0){
                resultStr += attrArray[i][keyName];
            }else{
                resultStr += ","+attrArray[i][keyName];
            }
        }
        return resultStr;
    }
})